import requests
from api.ihrmAdmDep import AmdDepApi
from common.assertTools import common_assret


class TestAddEmp(object):
    def setup_class(self):
        self.amd = AmdDepApi()
        resp = requests.post(url="http://ihrm2-test.itheima.net/api/sys/login",
                             json={"mobile": "13800000002", "password": "123456"})
        print("登录成功")
        token = resp.json().get("data")
        self.req_header = {"Authorization": token}



    # def test01_query_success(self):#查询成功
    #
    #     emp_id = "1549385280241397760"
    #     res = self.amd.query_adm(emp_id,self.req_header)
    #     print("查询", res.json())
    #
    #
    #     common_assret(res, 200,True,10000,"操作成功")
    def test02_query_idno(self):#ID不存在

        emp_id = "1549376"
        res = self.amd.query_adm(emp_id, self.req_header)
        print("查询", res.json())


        common_assret(res, 200,  False, 99999, "系统繁忙")

    def test03_add_success(self):  # 添加部门成功

        req_body = {"name": "会飞的猪", "code": "3452"}
        res = self.amd.add_adm_(self.req_header, req_body)
        print("添加", res.json())
        common_assret(res, 200,True,10000,"操作成功")
    def test04_addself(self):  # 添加部门缺参数

        req_body = None
        res = self.amd.add_adm_(self.req_header, req_body)
        print("添加", res.json())

        common_assret(res, 200,False,99999,"系统繁忙")

    def test05_modify_success(self):  # 修改成功

        req_body2 = {"name": "会飞的狗", "code": "3455"}
        emp_id="1549389630728695808"
        res = self.amd.modify_adm(emp_id, self.req_header, req_body2)
        print("修改", res.json())

        common_assret(res, 200, True, 10000, "操作成功")

    def test06_del_success(self):

        emp_id = "1549389630728695808"
        res = self.amd.del_adm(emp_id, self.req_header)
        print("删除", res.json())

        common_assret(res, 200, True, 10000, "操作成功")
